package com.lakeworks.processor;

import com.lakeworks.common.enums.ticket.TicketBackStatus;
import com.lakeworks.decision.BackTicketStateDecision;
import com.lakeworks.decision.base.Decision;
import com.lakeworks.domain.TktProcess;
import com.lakeworks.event.BackTicketEvent;
import com.lakeworks.processor.base.AbstractTicketProcessor;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.List;

@Component
public class BackTicketProcessor extends AbstractTicketProcessor<BackTicketEvent> {

    @Override
    public TktProcess apply(
            BackTicketEvent event
    ) {
        var process = super.apply(event);
        process.setTicketId(event.getTicket().getId());
        process.setComment("工厂:【"+event.getTicketBackStatus().getName()+"】");
        process.setRemark(event.getTicket().getRemark());
        if(TicketBackStatus.NOTSOLVE.equals(event.getTicketBackStatus())){
            process.setFlag(2);
        }
        List<Decision> list = new ArrayList<>();
        //添加工单反馈信息决策
        list.add(new BackTicketStateDecision(event.getTicket(), event.getTicketBackVo()));
        process.setDecisions(list);
        return process;
    }
}
